package com.jiang.myfm.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dell on 2016/12/6 0006.
 */
public class MainHeadImageAdapter extends FragmentStatePagerAdapter {
    private List<Fragment> mFragmentList=new ArrayList<>();

    public MainHeadImageAdapter(FragmentManager fm) {
        super(fm);
    }
//    public MainHeadImageAdapter(FragmentManager fm, List<Fragment> fragmentList) {
//        super(fm);
//        mFragmentList=fragmentList;
//    }

    public void addAll(List<Fragment> fragmentList){
        mFragmentList.addAll(fragmentList);
        notifyDataSetChanged();
//        Log.d("flag","第一个");
    }
    @Override
    public Fragment getItem(int position) {
        return mFragmentList==null?null:mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return  mFragmentList==null?0:mFragmentList.size();
    }


    public void reSetData(){
        mFragmentList=null;
        notifyDataSetChanged();
    }
}
